package net.csdn.business.common.domain.mirror.pop.enums;

import com.google.common.collect.Maps;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

import java.util.Map;
import java.util.Objects;

public class UserTokenEnum {

    @Getter
    @AllArgsConstructor
    public enum Type {
        GITHUB("github", "https://github.com/"),
        GITEE("gitee", "https://gitee.com/"),
        GITCODE("gitcode", "https://gitcode.com/"),
        ATOMGIT("atomgit", "https://atomgit.com/");

        private String platform;
        private String baseUrl;

        public static final Map<String, Type> MAP = Maps.newHashMap();

        static {
            for (Type type : Type.values()) {
                MAP.put(type.platform, type);
            }
        }

        public static Type parse(String platform) {
            if (StringUtils.isEmpty(platform)) {
                return null;
            }
            return MAP.get(platform);
        }

        public static boolean exists(String platform) {
            Type t = parse(platform);
            return Objects.nonNull(t);
        }
    }
}
